package com.林子祺.全名健康管理系统.dao.content.comment;

import com.林子祺.全名健康管理系统.entity.article.content.comment.CommentData;

import java.sql.*;

public class AllCommentPull {

    public static void pull() {
        Connection conn = null;
        Statement stmt = null;
        ResultSet rs = null;
        try {
            conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/content?useUnicode=true&characterEncoding=utf-8", "root", "blink102417");

            String sql = "select * from comment";

            stmt = conn.createStatement();

            rs = stmt.executeQuery(sql);

            while (rs.next()) {
                CommentData.InputData(rs.getString("username"),rs.getString("articleName"), rs.getString("comment"));
            }

        } catch (SQLException throwables) {
            throwables.printStackTrace();
        } finally {
            if (rs != null) {
                try {
                    rs.close();
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }
            if (stmt != null) {
                try {
                    stmt.close();
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }
            if (conn != null) {
                try {
                    conn.close();
                } catch (SQLException throwables) {
                    throwables.printStackTrace();
                }
            }
        }
    }
}
